package com.wondersgroup.wuhan_demo.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by liyaqing on 2018/5/7 0007.
 */

public class DataUtil {
    //把日期转为字符串
    public static String ConverToString(Date date) {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

        return df.format(date);
    }
    public static String ConverToString(Date date,String fomate) {
        DateFormat df = new SimpleDateFormat(fomate);

        return df.format(date);
    }


    //把字符串转为日期
    public static Date ConverToDate(String strDate) throws Exception {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd  hh:mm:ss");
        return df.parse(strDate);
    }

}
